import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { listData } from '/@/api/wh/ll/whTmLlH';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('master选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 12 },
  labelWidth: 80,
  autoAdvancedLine: 10,
  showAdvancedButton: true,
  alwaysShowLines: 10,
  schemas: [
    {
      label: '物料代码',
      field: 'basInv.cinvaddcode',
      component: 'Input',
    },
    {
      label: '物料编码',
      field: 'cinvCode',
      component: 'Input',
    },
    {
      label: '物料',
      field: 'cinvCode',
      fieldLabel: 'basInv.cinvaddcode' + 'basInv.cinvname',
      component: 'ListSelect',
      componentProps: {
        selectType: 'invSelect',
      },
    },
    {
      label: '计划量',
      field: 'iqty',
      component: 'Input',
      show: true,
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('存货编码'),
    dataIndex: 'cinvCode',
    key: 'cinvCode',
    width: 100,
    ifShow: false,
  },
  {
    title: t('存货编码'),
    dataIndex: 'basInv.cinvcode',
    key: 'basInv.cinvcode',
    width: 100,
  },
  {
    title: t('存货代码'),
    dataIndex: 'basInv.cinvaddcode',
    key: 'basInv.cinvaddcode',
    width: 100,
  },
  {
    title: t('存货名称'),
    dataIndex: 'basInv.cinvname',
    key: 'basInv.cinvname',
    width: 100,
  },
  {
    title: t('构成比例'),
    dataIndex: 'unitNumber',
    key: 'unitNumber',
    width: 100,
  },
  {
    title: t('类型'),
    dataIndex: 'spec',
    key: 'spec',
    width: 50,
  },
  {
    title: t('数量'),
    dataIndex: 'iqty',
    key: 'iqty',
    width: 100,
  },
  {
    title: t('在库量'),
    dataIndex: 'qty',
    key: 'qty',
    width: 100,
  },
];

const tableProps: BasicTableProps = {
  api: listData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    console.log('params', params);
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
  pagination: false,
};

export default {
  modalProps,
  tableProps,
  itemCode: 'id',
  itemName: 'id',
};
